#############################
###   GENERATE FIGURE 1   ###
###          EVS          ###
#############################
source("coefplot.stacked.R") ## this loads the plotting function

### you need to install the package haven to read the coefficient matrix
library(haven)

# Import value coefficients

cf <- read_stata("figure1_evs.dta")

cf <- data.frame(cf)

# Define names

namez <- c("Strong leader",
           "Democracy",
           "Democratic",
           "Children",
           "Abortion"
)

# Let's flip over the observations

namez <- namez[length(namez):1]

# Generate graph

pdf(paste0("figure1_evs", ".pdf"), width=4.5, height=6.5)

f2 <- stackplot(cf[,2:7], longnames=FALSE,return.position = TRUE,center.labels = TRUE, fifty=FALSE,
                main.label = "EVS",
                cex.pts = 1.25, box=TRUE, symmetric = FALSE, offset=-.041, cex.var=1  , pch.type = c(rep(c( 16,16,16),5),16,16,16))

points(.395,5.2, pch=16, cex=1.1)
text(.39, 5.2, "Import shock (IV)", cex=0.8, pos=4)

text(.0, 5.5, "Strong leader", cex=0.9, pos=4)
text(.0, 4.5, "Democracy", cex=0.9, pos=4)
text(.0, 3.5, "Democratic index", cex=0.9, pos=4)
text(.0, 2.5, "Children qualities", cex=0.9, pos=4)
text(.0, 1.5, "Abortion", cex=0.9, pos=4)

dev.off()

